﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>课程注册</title>
    <script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";
	var dialog=null;
	var terDialog=null;
	
    $(function (){
    
    	//$("#dateF").ligerDateEditor();
    	
    	//$("#dateT").ligerDateEditor();
    	
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        if(viewType=="modify"){
        	 $("#id").attr("readonly", "readonly").removeAttr("validate");
        }
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);
        
        //调整form-bar
        $(".form-bar").css("width","650px");        

    });
   
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + result.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("courseRegisterList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
    function selectCourse(){
    	dialog=$.ligerDialog.open({title: '选择课程',showMax: true, showToggle: true, showMin: true, isResize: true, modal: true,name:'winselector',width:600, height: 300, url: '${ctx}/qso/courseRegister/toSelect'});
    }
//     function selectTeacher(){
//     	terDialog=$.ligerDialog.open({title: '选择老师',showMax: true, showToggle: true, showMin: true, isResize: true, modal: true,name:'winselector',width:600, height: 300, url: '${ctx}/qso/teacher/toSelect'});
//     }
    /*
    *回填文本框里的课程编号、课程名称
    */
    function callBackOK(row){
    	$("#courseId").val(row.cid);
    	$("#courseName").val(row.title);
    	$("#terId").val(row.tid);
    	$("#terName").val(row.tName);
    	dialog.close();
    }
    /*
     *关闭弹出的课程选择页面
     */
    function callBackCancel(){
        dialog.close();
    }
//     /*
//      *回填文本框里的老师编号、课程名称
//      */
//     function callBackTeacherOK(row){
//      	$("#terId").val(row.id);
//      	$("#terName").val(row.title);
//      	terDialog.close();
//     } 
//     function callBackTeacherCancel(){
//     	terDialog.close();
//     }
 </script>
</head>

<body>
    <form name="mainform" method="post"  id="mainform" action="${ctx }/qso/courseRegister/save">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <input type="hidden" id="id" name="id" value="${command.id}"/>
        <input type="hidden" id="courseId" name="courseId" value="${command.course.id}"/>
        <input type="hidden" id="stuId" name="stuId" value="${command.student.stuId}"/>
        <input type="hidden" id="terId" name="terId" value="${command.teacher.terId}"/>
        <input type="hidden" id="crStatus" name="crStatus" value="<c:choose><c:when test="${viewType=='add'}">ED</c:when><c:otherwise>${command.crStatus}</c:otherwise></c:choose>" />
        <input type="hidden" id="crMessage" name="crMessage" value="${command.crMessage}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top:10px; margin-left:15px;">     
            <tr>
                <td align="right" class="l-table-edit-td">申请单编号:</td>
                <td align="left" class="l-table-edit-td" >
						${command.id}
                </td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">课程名称:</td>
                <td align="left" class="l-table-edit-td" >
                	<input  type="text"  readonly="readonly"  id="courseName" name="courseName" value="${command.course.title}" validate="{required:true}"/>
                </td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">老师名称:</td>
                <td align="left" class="l-table-edit-td" >
                	<input  type="text" readonly="readonly" id="terName" name="terName" value="${command.teacher.terName}" validate="{required:true}"/>
                </td>
                 <td align="left" class="l-table-edit-td" >
                 	<c:if test="${viewType!='detail'}">
                		<a onclick="selectCourse()" href="#">选择课程</a>
                	</c:if>
                </td>
            </tr>
<!--             <tr> -->
<!--             	<td align="right"  class="l-table-edit-td">申请意见:</td> -->
<!--                 <td align="left" class="l-table-edit-td" colspan="4"> -->
<%--                 	<textarea cols="200" rows="3" class="l-textarea" id="crMessage" name="crMessage" style="width:400px" <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> >${command.crMessage}</textarea> --%>
<!--                 </td> -->
<!--             </tr> -->
        </table> 
    </form>
</body>
</html>